home *** CD-ROM | disk | FTP | other *** search
- /*
- * $RCSfile: undoEntirePage.C,v $
- * $Revision: 1.1.1.1 $
- * $Date: 1996/05/04 21:56:04 $
- */
- /**********************************************************************
- * EXODUS Database Toolkit Software
- * Copyright (c) 1991 Computer Sciences Department, University of
- * Wisconsin -- Madison
- * All Rights Reserved.
- *
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * THE COMPUTER SCIENCES DEPARTMENT OF THE UNIVERSITY OF WISCONSIN --
- * MADISON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION.
- * THE DEPARTMENT DISCLAIMS ANY LIABILITY OF ANY KIND FOR ANY DAMAGES
- * WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * The EXODUS Project Group requests users of this software to return
- * any improvements or extensions that they make to:
- *
- * EXODUS Project Group
- * c/o David J. DeWitt and Michael J. Carey
- * Computer Sciences Department
- * University of Wisconsin -- Madison
- * Madison, WI 53706
- *
- * or exodus@cs.wisc.edu
- *
- * In addition, the EXODUS Project Group requests that users grant the
- * Computer Sciences Department rights to redistribute these changes.
- **********************************************************************/
-
-
- #include "sysdefs.h"
- #include "ess.h"
- #include "checking.h"
- #include "trace.h"
- #include "error.h"
- #include "list.h"
- #include "tid.h"
- #include "io.h"
- #include "lock.h"
- #include "object.h"
- #include "msgdefs.h"
- #include "thread.h"
- #include "latch.h"
- #include "semaphore.h"
- #include "link.h"
- #include "lsn.h"
- #include "bf.h"
- #include "pool.h"
- #include "log.h"
- #include "volume.h"
- #include "trans.h"
- #include "logrecs.h"
- #include "logaction.h"
- #include "openlog.h"
- #include "undo.h"
- #include "undo_extfuncs.h"
- #include "bf_extfuncs.h"
- #include "log_extfuncs.h"
- #include "log_intfuncs.h"
- #include "util_funcs.h"
- #include "thread_globals.h"
- #include "bf_globals.h"
- #include "trans_globals.h"
- #include "sm_macro.h"
- #ifdef INIT_LRC_IS_LSN
- # include "log_globals.h"
- #endif
-
- void
- undoEntirePage (
-
- LOGRECORDHDR *recordHeader
- )
- {
-
- GROUPLINK *groupLink;
- PID *pid;
- LOGRECORDINFO recordInfo;
- #ifdef INIT_LRC_IS_LSN
- LRC tempLRC;
- LRC *lrc = &tempLRC;
- #else
- LRC *lrc;
- #endif /* INIT_LRC_IS_LSN; */
- LSN lsn;
- FORCEMARK forceMark;
- PAGETYPE pageType;
- PAGE2SIZE page2size;
- SLOTTEDPAGE *slottedPage;
- MISSINGUPDATEINFO *missingUpdateInfo;
- BOOL actionDone; /* Indicates whether the action
- was ever performed on the page */
-
- TRPRINT(TR_IO, TR_LEVEL_1, ("lsn:%d", recordHeader->recordLSN));
-
- /* Remember pointer to missing update information */
- missingUpdateInfo = ( ((TRANSREC*)Active->transRec)->missingUpdateInfo);
-
- /* get a pointer to the page for the record */
- pid = &(recordHeader->actionPid);
- TRPRINT(TR_IO|TR_LOG, TR_LEVEL_2, ("pid:%d", pid->page));
-
-
- switch(recordHeader->action) {
- case LOG_ACTION_ENTIRE_SLOTTED:
- pageType = PAGE_SLOTTED;
- page2size = SLOTTED_PAGE2SIZE;
- break;
- case LOG_ACTION_ENTIRE_LARGE_NODE:
- pageType = PAGE_LARGENODE;
- page2size = LG_PAGE2SIZE;
- break;
- case LOG_ACTION_ENTIRE_LARGE_DATA:
- pageType = PAGE_LARGEDATA;
- page2size = LGDATA_PAGE2SIZE;
- break;
- case LOG_ACTION_ENTIRE_BTREE_PAGE:
- pageType = PAGE_INDEX;
- page2size = BTREE_PAGE2SIZE;
- break;
- case LOG_ACTION_ENTIRE_INDEXDESC:
- pageType = PAGE_INDEXDESC;
- page2size = INDEXDESC_PAGE2SIZE;
- break;
- default:
- SM_ERROR(TYPE_FATAL, esmINTERNAL);
- }
-
- /*
- * The current implementation of this function does not support
- * undo except for slotted pages. This is ok since all other
- * pages will be deallocated since this type of log record is
- * only used for new pages. Slotted pages are "permanently"
- * allocated, so they must have this operation undone.
- */
- if (pageType == PAGE_SLOTTED) {
-
- /* read in the page */
- if ((groupLink = bf_ReadPage(UserBufGroup, pid, page2size, BF_SEM)) == NULL) {
- SM_ERROR(TYPE_FATAL, Active->errno);
- }
- groupLink->pageHash->pageType = pageType;
-
- slottedPage = (SLOTTEDPAGE *) groupLink->bufFrame;
- SM_ASSERT(LEVEL_3, pid->page == recordHeader->actionPid.page);
- if (CHECK_SLOTTED_MAGIC(slottedPage)) {
- SM_ERROR(TYPE_FATAL, esmBADSLOTTEDMAGIC);
- }
-
- /*
- * See if the action was actually done. It must be since
- * this type of log record is only generated on the server.
- */
- actionDone = compareLRC(&(recordHeader->actionLRC), &(slottedPage->header.lrc) ) <= 0;
- SM_ASSERT(LEVEL_3, actionDone);
-
- lrc = &(slottedPage->header.lrc);
-
- INITPAGE(slottedPage, *pid, slottedPage->header.fid, FALSE, 0);
- /*
- * record that all unique numbers are used up, since we don't
- * know what to restore this to.
- */
- slottedPage->header.uniqueCount = 0;
-
- /* increment the lrc on the page */
- GENERATE_LRC(lrc);
-
- recordInfo.action = LOG_ACTION_SLOTTED_PAGE_FORMAT;
- recordInfo.type = LOG_REC_TYPE_COMPENSATION;
- recordInfo.imageCount = 1;
- recordInfo.actionPid = pid;
- recordInfo.actionLRC = lrc;
- recordInfo.imageSize[0] = sizeof(SLOTTEDHEADER) + sizeof(PAGESLOT);
- recordInfo.imageData[0] = (VOID *) &(slottedPage->slot[0]);
- recordInfo.nextUndoLSN = recordHeader->previousLSN;
- recordInfo.flags = NOFLAGS;
-
- if ((forceMark = writeLogRecord((TRANSREC *) Active->transRec, &recordInfo, &lsn, NOFLAGS)) < 0) {
- SM_ERROR(TYPE_FATAL, Active->errno);
- }
- DEPEND_LOG(groupLink->pageHash, forceMark, &lsn, lrc);
-
- /*
- * release the semaphore and unfix the page, dirty the page if
- * the action was done
- */
- signalSemaphore( &(groupLink->pageHash->semaphore) );
- bf_UnfixPage(groupLink, BF_DEFAULT, actionDone);
- }
-
- return;
- }
-